/*
 *  SSColoredButtonCell.m
 *  MESLib
 * 
 * Copyright 2003-2009 Starline Software Ltd
 * 
 * This file is part of MESLib.
 * 
 * MESLib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MESLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with MESLib. If not, see <http://www.gnu.org/licenses/>.
 */
//  Created by Tobias Haughton on Wed May 14 2003.
//

#import "SSColoredButtonCell.h"


@implementation SSColoredButtonCell

- (id)initTextCell:(NSString *)string backgroundColor:(NSColor *)color
{
   self = [super initTextCell:string];
   [self setBackgroundColor:color];
   return self;
}

- (id)initImageCell:(NSImage *)image backgroundColor:(NSColor *)color
{
   self = [super initImageCell:image];
   [self setBackgroundColor:color];
   return self;
}

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
   if(backgroundColor) {
      NSRect inset = NSInsetRect(cellFrame, 6, 4);
      [backgroundColor set];
      NSRectFillUsingOperation(inset, NSCompositeSourceAtop);
   }
   
   [super drawInteriorWithFrame:cellFrame inView:controlView];
}

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
   [super drawWithFrame:cellFrame inView:controlView];
}

- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
   [super highlight:flag withFrame:cellFrame inView:controlView];
}

- (void)setBackgroundColor:(NSColor *)color
{
   [backgroundColor release];
   [color retain];
   backgroundColor = color;
}

- (void)dealloc
{
   [backgroundColor release];
   [super dealloc];
}

@end
